<template>
    <div>
        <div>
            <!-- 头部导航 -->
            <van-nav-bar title="火车票" left-arrow @click-left="onClickLeft" />
        </div>
        <!-- 背景 -->
        <div>
            <div class="big-minge"></div>
            <div class="big-minges"></div>
        </div>
        <!-- 切换 -->
        <div class="cut-bigbox">
            <div class="cut-smallbox">
                <div>
                    <div class="switchover">
                        <div class="ticket-airticket">机票</div>
                        <div class="ticket-railwayticket">火车票</div>
                    </div>

                    <div class="switchover-box">
                        <div class="site">
                            <div @click="goAddressSelection('start')">{{ name }}</div>
                            <div><van-icon class-prefix="icon" name="quxain"></van-icon></div>
                            <div @click="goAddressSelection('end')">{{ names }}</div>
                        </div>
                        <div class="date-box">
                            <van-cell :value="date" @click="show = true" style="font-size: .7rem; line-height: 1rem;" />
                            <van-calendar v-model="show" @confirm="onConfirm" color="#00C9E2" />

                        </div>

                        <div class="choice-box">
                            <van-checkbox v-model="checked">只看高铁/动车</van-checkbox>
                            <van-checkbox v-model="checkeds">学生票</van-checkbox>
                        </div>
                        <div class="search-box" @click="goSearchQuery">搜索</div>
                    </div>



                </div>
            </div>
        </div>

        <!-- 抢票 订单 按钮-->
        <div class="button-box">
            <!-- 占位 -->
            <div></div>
            <div>
                <div class="icon-box1">
                    <van-icon class-prefix="icon" name="qianggou" @click="goTicketGrabbing"></van-icon>
                </div>
                <div class="headline">抢票</div>
            </div>
            <div>
                <div class="icon-box2">
                    <van-icon class-prefix="icon" name="dingdan" @click="goOrderForm"></van-icon>
                </div>
                <div class="headline">我的订单</div>
            </div>
            <!-- 占位 -->
            <div></div>
        </div>

    </div>
</template>

<script>

export default {
    data() {
        return {
            //只看高铁/动车
            checked: false,
            //筛选学生票
            checkeds: false,

            //日历显示
            date: '选择日期',
            show: false,
            //起始位置
            name: "",
            //目的地
            names: "",
        };
    },
    methods: {
        //返回上一级
        onClickLeft() {
            this.$router.go(-1)
        },
        // 跳转到抢票
        goTicketGrabbing() {
            this.$router.push("/TicketGrabbing")
        },
        goOrderForm() {
            this.$router.push("/OrderForm")
        },
        // 日期选择
        formatDate(date) {
            return `${date.getMonth() + 1}/${date.getDate()}`;
        },
        onConfirm(date) {
            this.show = false;
            this.date = this.formatDate(date);
        },
        // 跳转到地址选择
        goAddressSelection(start) {
            this.$router.push({ path: "/AddressSelection", query: { start } });
        },
        // 跳转到搜索
        goSearchQuery() {
            this.$router.push("/SearchQuery")
        }
    },

    created() {
        this.name = sessionStorage.getItem("name") || "北京"
        this.names = sessionStorage.getItem("names") || "上海"

    },

};
</script>
<style scoped>
/* 导航样式 */
.van-nav-bar {
    background-color: #00C9E2;
}

.van-nav-bar__title {
    color: white;
}

/* 背景图 */
.big-minge {
    width: 100%;
    height: 1.8rem;
    background-image: url(//s.qunarzz.com/train_touch/pictures/top_title.png);
    background-size: cover;
}

.big-minges {
    width: 100%;
    height: 1.5rem;
    background-color: #00D9EE;
    position: absolute;
}

/* 切换  火车票 机票 */
/* 切换大盒子 */
.cut-bigbox {
    width: 100%;
    height: 8rem;
}

/* 切换小盒子 */
.cut-smallbox {
    height: 8rem;
    margin-left: .3rem;
    margin-right: .3rem;
    background-color: rgb(255, 255, 255);
    border-radius: 10px;
    box-shadow: 0 1px 0 1px #c7c7c7;
    position: relative;
    bottom: 20px;
    display: flex;
    flex-direction: column;
}

/* 机票火车票 */
.switchover {
    width: 100%;
    height: 1.5rem;
    border-radius: 10px 10px 0 0;
    display: flex;

}

.switchover div {
    width: 50%;
    border-radius: 10px 10px 0 0;
    text-align: center;
    font-size: .5rem;
}

/* 机票切换 */
.ticket-airticket {
    line-height: 1.3rem;
    background-color: #F7F7FB;
}

/* 火车票切换 */
.ticket-railwayticket {
    position: relative;
    bottom: 10px;
    line-height: 1.8rem;
    background-color: #fff;
}

/* 地址 日期 确认 盒子 */
.switchover-box {
    margin-left: .5rem;
    margin-right: .5rem;
}

/* 地址选择 */
.site {
    margin-top: .3rem;
    display: flex;
}

.site div {
    width: 50%;
    height: 1.5rem;
    font-size: .8rem;
    text-align: center;
    border-bottom: 1px solid #dedede;
}

.icon-quxain {
    font-size: 1rem;
}


/* 日期选择 */
.date-box {
    width: 100%;
    height: 1.5rem;
    display: flex;
    line-height: 1.5rem;
    font-size: .5rem;
    border-bottom: 1px solid #dedede;

}

.date-week {
    margin-left: .3rem;
    font-size: .35rem;
    color: #b8b8b8;
}

/* 车票选择 */
.choice-box {
    width: 100%;
    display: flex;
    justify-content: space-between;
    height: 1.5rem;
}

/* 搜索按钮 */
.search-box {
    width: 100%;
    background-color: #FF8300;
    height: 1.2rem;
    text-align: center;
    line-height: 1.2rem;
    color: #fff;
    font-size: .5rem;
    border-radius: 15px;

}


/* 抢票  我的订单 */
.button-box {
    width: 100%;
    height: 2.5rem;
    display: flex;
    justify-content: space-between;
    margin-top: .5rem;
}

.icon-box1 {
    width: 1.5rem;
    height: 1.5rem;
    background-color: #FFDF7C;
    text-align: center;
    border-radius: 50%;
    line-height: 1.5rem;
    margin-top: .2rem;
    box-shadow: 1px 1px 2px 1px #c7c7c7;
    border: 1px solid #ebebeb;
}

.icon-box2 {
    width: 1.5rem;
    height: 1.5rem;
    background-color: #6890F4;
    text-align: center;
    border-radius: 50%;
    line-height: 1.5rem;
    margin-top: .2rem;
    box-shadow: 1px 1px 2px 1px #c7c7c7;
    border: 1px solid #ebebeb;

}

.headline {
    margin-top: .2rem;
    text-align: center;
    font-size: .35rem;
}

.icon-qianggou {
    font-size: 1rem;
    color: #fff;
}

.icon-dingdan {
    font-size: 1rem;
    color: #fff;
    ;
}
</style>